# Python 2.6.4
# Project Euler, Problem 14
# Copyright 2010 Talha Zaman

def seq(n):
    if n%2==0: return n/2
    else: return 3*n+1

maxi, maxlen = 0, 0
dic = {}
for i in range(1,1000000):
    length = 1
    n = i
    while (n!=1):
        n, length = seq(n), length+1
        if dic.has_key(n):
            length += dic[n] - 1
            break
    if maxlen < length : maxi, maxlen = i, length
    dic[i]=length
print "maxi:", maxi, "maxlen:", maxlen
